package com.woohua.thread.create;

import java.util.concurrent.*;

/***
 * @title ExecutorsDemo
 * @description: Executors 构建   线程池
 * @author woo hua
 * @version 1.0.0
 * @create 2023/3/9 13:14
 **/
public class ExecutorsDemo {

    public static void main(String[] args) {
        // 创建线程池
        ExecutorService executorService = Executors.newFixedThreadPool(1);

        Future<Integer> future = executorService.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                return 4;
            }
        });

        try {
            Integer integer = future.get();
            System.out.println(integer);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
